const removeDuplicates = function (nums) {
  let slow = 0
  let fast = 0
  while (fast < nums.length) {
    if (nums[slow] === nums[fast]) {
      fast++
    } else {
      slow++
      nums[slow] = nums[fast]
    }
  }
  console.log(nums)
  return slow + 1
}

let nums = [1, 1, 2]

const k = removeDuplicates(nums)
console.log(k)
